package xyz.cerberu.cet.user.domain;

import org.hibernate.validator.constraints.Length;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;

/**
 * @author β世界
 * Created on 19:00
 * @Description 用户实体类对象
 */
@Validated
public class User implements Serializable {

    /** 用户的唯一标识 **/
    private String uid;

    /** 用户的用户名 **/
    @NotBlank(message = "用户名不能为空")
    @Length(min = 5,max = 15,message = "用户名长度应该在5-15位之内")
    private String username;

    /** 用户密码(前台传递的应该是MD5加密过的) **/
    @NotBlank(message = "密码不能为空")
    @Length(min = 0,max = 32,message = "密码长度有问题")
    private String password;

    @NotBlank(message = "邮箱不能为空")
    @Email(message = "请输入正确的邮箱格式")
    private String email;

    /** 用户的头像信息 **/
    private String picture;

    /** 用户角色实体 **/
    private Role role;

    public User() {
    }

    public User(String uid, @NotBlank(message = "用户名不能为空") @Length(min = 5, max = 15, message = "用户名长度应该在5-15位之内") String username, @NotBlank(message = "密码不能为空") @Length(min = 5, max = 15, message = "密码长度应该在5-15位之内") String password, @NotBlank(message = "邮箱不能为空") @Email(message = "请输入正确的邮箱格式") String email, Role role,String picture) {
        this.uid = uid;
        this.username = username;
        this.password = password;
        this.email = email;
        this.role = role;
        this.picture = picture;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setEmail(@Email String email) {
        this.email = email;
    }

    public void setRole(Role role) {
        this.role = role;
    }
    public String getUid() {
        return uid;
    }

    public String getUsername() {
        return username;
    }

    public String getPassword() {
        return password;
    }

    public String getEmail() {
        return email;
    }

    public Role getRole() {
        return role;
    }

    public String getPicture() {
        return picture;
    }

    public void setPicture(String picture) {
        this.picture = picture;
    }

    @Override
    public String toString() {
        return "User{" +
                "uid='" + uid + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", email='" + email + '\'' +
                ", picture='" + picture + '\'' +
                ", role=" + role +
                '}';
    }
}
